package com.example.demo.AppUtil.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.example.demo.config.ben.BO.UserInfoInTokenBO;

/*
 * @Author:大力王
 * @Date:2024/6/10-10-21:40
 * 开始了
 */
public class AuthUserContext {
    private static final ThreadLocal<UserInfoInTokenBO> USER_INFO_IN_TOKEN_HOLDER = new TransmittableThreadLocal<>();

    public static UserInfoInTokenBO get() {
        return USER_INFO_IN_TOKEN_HOLDER.get();
    }

    public static void set(UserInfoInTokenBO userInfoInTokenBo) {
        USER_INFO_IN_TOKEN_HOLDER.set(userInfoInTokenBo);
    }

    public static void clean() {
        if (USER_INFO_IN_TOKEN_HOLDER.get() != null) {
            USER_INFO_IN_TOKEN_HOLDER.remove();
        }
    }
}
